#include <cstring>
#include <cassert>
#include <cstdio>
using namespace std;

void *my_memcpy(void *dst, const void *src, size_t cnt)
{
    if (!dst || !src || cnt == 0)
        return;

    void *ans = dst;
    while (cnt--)
    {
        *(char *)dst = *(char *)src;
        dst = (char *)dst + 1;
        src = (char *)src + 1;
    }
    return ans;
}

void *my_memmove(void *dst, const void *src, size_t cnt)
{
    if (!dst || !src || cnt == 0)
        return;

    void *ans = dst;
    // 从后往前
    if (src < dst)
    {
        while (cnt--)
        {
            *((char *)dst + cnt) = *((char *)src + cnt);
        }
    }
    else
    {
        while (cnt--)
        {
            *(char *)dst = *(char *)src;
            dst = (char *)dst + 1;
            src = (char *)src + 1;
        }
    }

    return ans;
}
